import Vue from 'vue'
import App from './App.vue'
//6.2 引入路由文件
import router from './router/index'

import './styles/iconfont.css'
//引入样式初始化
import './styles/reset.css'
Vue.config.productionTip = false

//引入
import { Toast, Notify, Image as VanImage, Dialog, NavBar, Icon, Uploader, Field, ActionSheet, Tab, Tabs, List, PullRefresh, Button, SwipeCell, Empty, Search } from "vant";
Vue.use(Toast);
Vue.use(Notify);
Vue.use(VanImage);
Vue.use(Dialog)
Vue.use(NavBar);
Vue.use(Icon);
Vue.use(Uploader);
Vue.use(Field)
Vue.use(ActionSheet);
Vue.use(Tab);
Vue.use(Tabs);
Vue.use(List);
Vue.use(PullRefresh);
Vue.use(Button);
Vue.use(SwipeCell);
Vue.use(Empty)
Vue.use(Search);
import request from './utils/request'
// 全局过滤器 - 在任意组件都能调用
// Vue.filter("过滤器名", (值) => {return "返回处理后的值"})
Vue.filter('imgUrl', val => {

  return !val ? require('./assets/logo.png') : val.indexOf("http") === -1 ? request.defaults.baseURL + val : val
}
)
// 通过过滤器实现时间的格式化处理
Vue.filter('formdata', (val) => {
  if (val) {
    return val.replace('T', ' ').replace('.000Z', '')
  }
})

//自定义指令
Vue.directive('focus', {
  update(el) {
    el.focus()
  }
})

new Vue({
  //6.3添加路由到vue
  router,
  render: h => h(App),
}).$mount('#app')
